package odgs.message.client;

import java.util.HashMap;
import java.util.List;

import odgs.Connection;
import odgs.ContentsFile;
import odgs.Transaction;
import odgs.message.Message;
import odgs.message.MessageHandler;
import odgs.message.MessageProcessor;
import odgs.transaction.ExecuteTransction;

public class ExecuteTransactionResponseHandler implements MessageHandler
{

	public void execute(MessageProcessor processor, Message msg, Connection con)
	{
		if(msg.getResult() < 0)
		{
			Transaction tran = (Transaction) msg.get("transaction");
			processor.getTransactionManager().error(msg.getResult(), tran);
		}
		else
		{
			List<ContentsFile> file =  (List<ContentsFile>) msg.get("files");
			ExecuteTransction tran = (ExecuteTransction) msg.get("transaction");
			tran = (ExecuteTransction) processor.getTransactionManager().getTransaction(tran.getRequestId());
			tran.setExecuteManager(processor.getExecuteManager());
			processor.getTransactionManager().receiveFile(file, tran);
		}
	}
}
